<!--
 * @Description: 基本布局
 * @Author: wangfuwei
 * @Date: 2020-12-01 23:26:40
 * @LastEditors: wangfuwei
 * @LastEditTime: 2021-01-02 21:11:56
 * @FilePath: /horizon-frontend/src/layouts/BasicLayout.vue
-->
<template>
  <top-layout :menus.sync="menus">
    <a-layout :class="{ 'ant-layout-has-sider': hasSider }">
      <!-- 侧边菜单 -->
      <side-menu v-if="hasSider" :menus="menus" />

      <!-- 右侧区域 -->
      <a-layout :style="{ minHeight: 'calc(100vh - 52px)', height: 'calc(100vh - 52px)' }">
        <a-layout-content :style="{ height: '100%' }">
          <!-- 标签页 -->
          <multi-tab v-if="hasSider" />

          <!-- 正文区域 -->
          <transition name="page-transition">
            <page-view />
          </transition>
        </a-layout-content>
      </a-layout>
    </a-layout>
  </top-layout>
</template>

<script>
import { appMixin } from "@/utils/mixin";
import TopLayout from "./TopLayout";
import PageView from "./PageView";
import SideMenu from "@/components/SideMenu";

export default {
  name: "BasicLayout",
  mixins: [appMixin],
  components: {
    TopLayout,
    PageView,
    SideMenu,
  },
  data() {
    return {
      menus: [],
    };
  },

  computed: {
    /**
     * 是否有侧边栏菜单
     */
    hasSider() {
      return this.menus.length > 0;
    },
  },
};
</script>

<style lang="less" scoped>
.drawer-sider {
  widows: 208px;
  padding-top: 52px;
}

/** 具体内容页加载动画 */
.page-transition-enter {
  opacity: 0;
}

.page-transition-leave-active {
  opacity: 0;
}

.page-transition-enter .page-transition-container,
.page-transition-leave-active .page-transition-container {
  -webkit-transform: scale(1.1);
  transform: scale(1.1);
}
</style>

<style lang="less" scoped>
/deep/ .ant-tabs-bar {
  margin: 0;
  border-top: 1px solid hsla(0, 0%, 89%, 0.9);
  border-bottom: 1px solid hsla(0, 0%, 89%, 0.9);
  height: 40px;
  background-color: #f6f7f9;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.15);
  color: #637da7;

  .ant-tabs-nav-wrap {
    margin-bottom: 0;

    .ant-tabs-tab {
      margin: 0 30px 0 0;
      padding: 0;
      line-height: 40px;
      user-select: none;

      &:first-child {
        margin: 0 15px;
        font-size: 18px;

        i {
          font-size: 16px;
          margin: 0;
          visibility: visible;
        }
      }

      &:not(.ant-tabs-tab-active):first-child {
        color: #a7b5d3;
      }

      .close {
        margin: 0;
        color: #637da9;
        font-size: 12px;
        margin-left: 2px;
        visibility: hidden;
      }

      &:hover {
        .close {
          visibility: visible;
        }
      }
    }

    .ant-tabs-ink-bar {
      bottom: 2px;
    }
  }
}

/deep/ .ant-dropdown-menu {
  border-radius: 0;

  .ant-dropdown-menu-item {
    font-size: 12px;
    line-height: 20px;
  }
}
</style>
